package server.imp;

import java.io.IOException;
import java.net.ServerSocket;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import server.Server;
import service.impl.RegisterServiceImpl;

public class RegisterServerImpl extends Thread implements Server{
	
	private final static Logger logger = LogManager.getLogger(ChatServerImpl.class);
	
	private ServerSocket server;
	
	public void server(){
		try {
			server = new ServerSocket(8004);
			logger.info("server start");
			while (true) {
				new RegisterServiceImpl(server.accept()).start();
			}
		} catch (IOException e) {
			logger.error(e);
		}
	}
	
	@Override
	public void run(){
		server();
	}
	
	public static void main(String[] args) {
		new RegisterServerImpl().server();
	}

	@Override
	public void shutdown() {
		try {
			server.close();
		} catch (IOException e) {
			logger.warn(e);
		}
		
	}

}
